package com.supermap.dataservice.cloud.commodity;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author aqua
 * @desc
 * @date 2019年04月11 15:54
 * @email 1301584033@qq.com
 */
@Mapper
public interface CommodityMapper {

    @Select("select count(1) from product where if(isnull(#{commodityName}),1=1,product_name like concat('%',#{commodityName},'%')) order by timestamps desc")
    Integer getCommodityListCountSum(@Param("commodityName") String commodityName);

    @Select("select *,(select name from site where t.user_id=userid)as userName from product t where   if(isnull(#{commodityName}),1=1,product_name like concat('%',#{commodityName},'%')) order by timestamps desc  limit #{pageNum},#{pageSize}")
    List<Map<String,Object>> getCommodityList(@Param("commodityName") String commodityName, @Param("pageNum")Integer pageNum, @Param("pageSize")Integer pageSize);


}
